<thead>
	<th><input type="checkbox" id="checkAll" /></th>
	<th>STT</th>				<!--1-->
    <th>Mã kết luận</th>		<!--2-->
    <th>P/B thực hiện</th>		<!--3-->
    <th>Nội dung kết luận</th>	<!--4-->
    <th>Ngày hoàn thành</th>	<!--5-->
    <th>Tình trạng</th>			<!--6-->
    <th>Kết quả thực hiện</th>	<!--7-->
    <th>YC P.KH</th>			<!--8-->
    <th>Điểm</th>				<!--9-->
    <th>Hình thức KL</th>		<!--10-->
    <th>Số văn bản</th>			<!--11-->
    <th>Ngày giao ban</th>		<!--12-->
    <th>Người kết luận</th>		<!--13-->
    <th>Loại kết luận</th>		<!--14-->
    <th>Kết luận khác</th>		<!--15-->
   <!-- <th>Dự kiến tiến độ</th>	16-->
    <th>Phê duyệt</th>			<!--17-->
    <th>TP duyệt</th>			<!--18-->
   <!-- <th>Lý do NOK</th>			19-->
    <th>Ghi chú</th>			<!--20-->
    
    <th>Ngày giao ban</th>		<!--21-->   
    <th>Loại giao ban</th>		<!--22-->   
    <th>Chủ trì</th>			<!--23-->
    <th>Trọng số điểm</th>		<!--24-->
    <th>Chuyên quản</th>		<!--25-->
    <th>Trùng với KLGB</th>		<!--26-->
    <th>Mã CV gia hạn</th> 		<!--27-->
    <th>CĐ Qúa hạn</th>			<!--28-->
    <th>CĐ Điều chỉnh</th>		<!--39-->
    <!--<th>Tổng điểm</th>			30-->
    
    <th>YC TP</th>				<!--31-->
    <th>Sửa</th>				<!--33-->
    <th>Xoá</th>				<!--34-->    
</thead>
<tbody>
	<?php $i=1; 
	$ngay_hien_tai = strtotime(gmdate('Y-m-d',time()+7*3600));			
	$ngay_canh_bao = 3*86400;
	$idgiaoban="";
	$list_nhanvien = $this->model->local_nhanvien();
	/*
	foreach($datas as $item){
		$idgiaoban.=",".$item->id;
	}
	$idgiaoban = substr($idgiaoban,1);
	$phongbanthuchien = $this->model->getPhongbanthuchien($idgiaoban);
	$phongban = $phongbanthuchien['phongban'];
	*/
	foreach($datas as $item){
		$id = $item->id;
		$codes = str_pad($id, 6, "0", STR_PAD_LEFT);
		
		if($item->ngaygiaoban != '0000-00-00' && !empty($item->ngaygiaoban)){
			$ngaygiaoban = date('d-m-Y',strtotime($item->ngaygiaoban));
		}
		else{
			$ngaygiaoban = "";	
		}
		
		$tinh_trang = "";
		$mau="";
		if($item->ngayhoanthanh != '0000-00-00' && !empty($item->ngayhoanthanh)){
			$ngayhoanthanh = date('d-m-Y',strtotime($item->ngayhoanthanh));			
			$ngay_hoan_thanh = strtotime($item->ngayhoanthanh);			
			$kq = $this->model->tinh_trang($ngay_hien_tai, $ngay_hoan_thanh, $ngay_canh_bao);
			if($kq['status'] == 0)$tinh_trang = "Bình thường";
			if($kq['status'] == 1)$tinh_trang = "Quá hạn";
			if($kq['status'] == 2)$tinh_trang = "Trong hạn";//(($kq['status']==0)?"bình thường":($kq['status']==1)?"quá hạn":"trong hạn");
			$mau = "style='".$kq['color']."'";			
		}
		else{
			$ngayhoanthanh = "";	
		}
			
		$diem=0;
		if($item->chamdiemdc!=0 )
			$diem = $item->chamdiemdc;
		else
			$diem = ($item->chamdiem!=0)?$item->chamdiem:0;
		
		
		
		$list = "";
		if(isset($lists[$item->id])){
			$list = $lists[$item->id];
		}
		
		
		$pbth = "";
		$title = "";
		$diemdc=0;
		$arrklpb = $this->model->table("klphongban")->select("tendonvi, diemdieuchinh, ngayhoanthanh, types")->where("idkl",$item->id)->find_all();
		$cpb=0;
		foreach($arrklpb as $klpb) {			
			if($cpb<3) {
				$pbth .= "- ".$klpb->tendonvi."<br \>";				
			}
			//$title .= "- ".$klpb->tendonvi."&#010;";
			if($klpb->types == 1) {
				$sub_ngay_hoan_thanh = strtotime($klpb->ngayhoanthanh);	
				$sub_kq = $this->model->tinh_trang($ngay_hien_tai, $sub_ngay_hoan_thanh, $ngay_canh_bao);
				$title .= "<div style='width:100%; ".$sub_kq['color']."'>- ".$klpb->tendonvi."</div>";
			} else {
				$title .= "<div style='width:100%; ".$kq['color']."'>- ".$klpb->tendonvi."</div>";
			}
			if(isset($klpb->diemdieuchinh))
				$diemdc+=$klpb->diemdieuchinh;
			$cpb++;
		}
		if(count($arrklpb) > 0)
			$pbth = substr($pbth,0,-6);
		//$title = substr($title,0,-6);		
		
		?>
        <tr>
        	<td class="tcenter"><input name="keys[]" type="checkbox" id="<?=$item->id;?>"/></td>
            <td style="text-align:center !important;" class="tcenter"><?=$i;?></td><!--1-->
            <td class="tcenter" <?=$mau?>><?=$codes;?></td><!--2-->
            <td class="abcdef"><?=(count($arrklpb)<=3)?$pbth:$pbth.'<br />......'?>
            	<div class="popup">			
				<?=$title?>
                </div>
  			</td><!--3-->
            <td class="noidungct" style="white-space:inherit !important;" ><?=$item->noidung;?>
            <?php if($list != ""){?>
            	 <ul style="color:#777;">
            	<?php $ks=1;  foreach($list as $k=>$val)
				{
				//	$codes2 = "&nbsp;&nbsp;".$ks."/ ".$codes."-".$k.": ".$val;
					$codes2 = "&nbsp;&nbsp;".$ks."/ ".$val;
					?>
                	<li><?=$codes2;?></li>
                <?php $ks++;}?>    
                 </ul>	
            <?php }?>
            </td><!--4-->
            <td ><?=$ngayhoanthanh;?></td><!--5-->            
            <td ><?=$tinh_trang?>
            <div id="<?=$item->id;?>" type ="tinhTrangDetail" class="fright rights fa fa-area-chart c04aeda cursor f30">&nbsp;&nbsp;</div>
            </td><!--6-->
            <td >             
                 
            	   <div id="<?=$item->id;?>" type ="traKetquaDetail" class="fright rights fa fa-sort-alpha-desc c04aeda cursor f13">&nbsp;&nbsp;</div>

                   <div id="<?=$item->id;?>" type ="traKetqua"   class="fright rights fa fa-upload c04aeda cursor f14">&nbsp;&nbsp;</div>
           
            </td><!--7-->           
            <td id="<?=$item->id;?>" type="ycpkh">
            	<span><?=$item->yeucauphongkh;?></span>                
            	<div id="<?=$item->id;?>" type ="ycpkhDetail" class="fright rights fa fa-sort-alpha-desc c04aeda cursor f13">&nbsp;&nbsp;</div>
                <?php if(isset($rights['yc_pkh'])){?>
                	<div id="<?=$item->id;?>" type ="ycpkh" class="fright rights fa fa-download c04aeda cursor f14">&nbsp;&nbsp;</div>
                <?php }?>
            </td><!--8-->
            <td style="text-align:center;"><?=$diem?></td><!--9-->
            <td ><?=$item->hinhthucketluan;?></td><!--10-->
            <td ><?=$item->sovanban;?></td><!--11-->
            <td ><?=$ngaygiaoban;?></td><!--12-->
            <td ><?=(isset($list_nhanvien[$item->nguoiketluan]))?$list_nhanvien[$item->nguoiketluan]:"";?></td><!--13-->
            <td ><?=$item->loaiketluan;?></td><!--14-->
            <td ><?=$item->ketluankhac;?></td><!--15-->
        	<!--    <td >#</td>16-->
            <td >
             	 <?php if(isset($rights['pheduyet'])){?>
             	 <select id="<?=$item->id;?>" class="combo loaipheduyet" style="width:100% !important;">
                 	 <option value="">Chọn tình trạng</option>
                 	 <?php foreach($loaipheduyet as $idpd=>$name){?>
                    	 <option <?php if($idpd == $item->idpd2){?> selected="selected" <?php }?> value="<?=$idpd;?>"><?=$name;?></option>	
                     <?php }?>
                 </select>
                 <?php }?>
             </td><!--17-->
             <td class="tcenter">
             <?php if(isset($rights['tp_pheduyet'])){?>
             	<input class="tpduyet" <?php if($item->tpduyet == 1){?> checked="checked" <?php }?> id="<?=$item->id;?>" type="checkbox" />
             <?php }?>
             </td><!--18-->
          <!--   <td >#</td>19-->
             <td ><?=$item->ghichu;?></td><!--20-->
    
            <td style="text-align:center;" ><?=$ngaygiaoban;?></td><!--21-->
            <td ><?=$item->loaigiaoban;?></td><!--22-->
            <td ><?=(isset($list_nhanvien[$item->chutri]))?$list_nhanvien[$item->chutri]:"";?></td><!--23-->
            <td ><?=$item->trongsodiem;?></td><!--24-->
            <td ><?php
                if(!empty($item->tenchuyenquan)) {
                    $tenchuyenquan = substr($item->tenchuyenquan,1);
                    $tenchuyenquan = substr($item->tenchuyenquan,0,-1);
                    $tenchuyenquan=str_replace(",","<br />",$tenchuyenquan);
                    echo $tenchuyenquan;
                }                    
                ?>
            </td><!--25-->
            <td ><?=$item->trungketluan;?></td><!--26-->
            <td ><?=$item->macongvangiahan;?></td><!--27-->
            
            <td style="text-align:center !important;" >
            	<div id="<?=$item->id;?>" type ="lichsuchamdiem" class="fright rights fa fa-sort-alpha-desc c04aeda cursor f13">&nbsp;&nbsp;</div>
            </td><!--28-->
            <td style="text-align:center !important;" >
           		 <div style="float:left;">&nbsp;&nbsp;<?=$diemdc?> </div>
                 <?php if(isset($rights['cd_dieuchinh'])){?>
            		<div id="<?=$item->id;?>" type ="lichsuchamdiemqh" class="fright rights fa fa-sort-alpha-desc c04aeda cursor f13">&nbsp;&nbsp;</div>			
				 <?php }?>
                
                <div id="<?=$item->id;?>" type ="chamdiemdc" class="fright rights fa fa-upload c04aeda cursor f14">&nbsp;&nbsp;</div>
            </td><!--29-->
            <!--<td style="text-align:center !important;" >
            	<span></span>
            </td>30-->
           
           <td id="<?=$item->id;?>" type="yctp">
				
            	<!--<span><?=$item->yctp;?></span> -->
              
            	<div id="<?=$item->id;?>" type ="yctpDetail" class="fright rights fa fa-sort-alpha-desc c04aeda cursor f13">&nbsp;&nbsp;</div>
        		<?php if(isset($rights['yc_tp'])){?>
                	<div id="<?=$item->id;?>" type ="yctp" class="fright rights fa fa-download c04aeda cursor f14">&nbsp;&nbsp;</div>
                <?php }?>
            </td><!--31-->
            
            <td class="tcenter pleft15">
            	<?php if(isset($rights['edit'])){?>
            	<a href="<?=base_url()?>klgb/edit/<?=$item->id;?>.html"><span class="icon icon-edit w20 h20 dblock fleft mleft5 c04aeda" id="<?=$item->id;?>"></span></a>
                <?php }?>
            </td><!--33-->
            <td class="tcenter pleft15">
            	<?php if(isset($rights['delete'])){?>
                <a class="deleterow" idrow="<?=$item->id;?>" href="<?=base_url()?>klgb/delete/<?=$item->id;?>.html"><span class="icon icon-delete w20 h20 dblock fleft mleft5 c04aeda" id="<?=$item->id;?>"></span></a>
                <?php }?>
            </td><!--34-->
        </tr>
    <?php $i++;}?>
</tbody>
